﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OrchardFork.Framework.Mvc.Routes;

namespace OrchardFork.Framework.Environment
{
    public class DefaultCnvpShell : ICnvpShell
    {
        private readonly IEnumerable<IRouteProvider> _routeProviders;
        private readonly IRoutePublisher _routePublisher;

        public DefaultCnvpShell(IEnumerable<IRouteProvider> routeProviders, IRoutePublisher routePublisher)
        {
            _routeProviders = routeProviders;
            _routePublisher = routePublisher;
        }

        public void Activate()
        {
            var allRoutes = new List<RouteDescriptor>();
            allRoutes.AddRange(_routeProviders.SelectMany(provider => provider.GetRoutes()));

            _routePublisher.Publish(allRoutes);
        }

        public void Terminate()
        {
            
        }
    }
}
